
#ifndef __LOG_DEFINITIONS___
#define __LOG_DEFINITIONS___

#include "logger.h"
#include <iostream>
#include <string>
#include <sstream>

namespace woe
{
	//
	//	log level is the basic mechanism for group log event in log system
	//	we defined a couple of most used
	//
	enum LogLevel
	{
		LL_DEBUG,
		LL_INFO,
		LL_WARN,
		LL_ERROR,
		LL_FATAL,
	};

	//
	//	log label is used for grouping log events, this is an simple implementation of multiple loggers
	//	so 16 bits of log
	//
	enum LogLable
	{
		LLB_ALL			=	0x00000000,
		LLB_CONSOLE		=	0x00000001,
		LLB_FILE		=	0x00000002,
		LLB_UI			=	0x00000004,
		LLB_Logic_X		=	0x00000010,
		LLB_Logic_Y		=	0x00000020,
		LLB_Logic_Z		=	0x00000040,
	};

	//
	//	define output string stream for log macros
	//
#ifdef	UNICODE
	typedef std::wostringstream	tostringstream;
#else
	typedef std::ostringstream	tostringstream;
#endif

	//
	//	default macro is defined to make log interface easy to use
	//	you can define your owner macro and your owner loggers too.
	//
#define LOG(lvl, message)	do{			\
	woe::tostringstream oss;			\
	oss<<message;					\
	woe::Logger::instance()->log(lvl, woe::LLB_ALL, oss.str());		\
	}				\
	while(0);

	//
	//	for iostream style log
	//
#define LOG_DEBUG(message)	LOG(woe::LL_DEBUG, message)
#define LOG_WARN(message)	LOG(woe::LL_WARN, message)
#define LOG_INFO(message)	LOG(woe::LL_INFO, message)
#define LOG_ERROR(message)	LOG(woe::LL_ERROR, message)
#define LOG_FATAL(message)	LOG(woe::LL_FATAL, message)


	//
	//	for variable parameters
	//
	class TUTIL_API LoggerV
	{
	public:
		static void log(	const short& lvl, 
							const short& label, 
							const char* szFmt, 
							va_list ap);
	
		static void debug(const char* szFmt,  ...);

		static void info(const char* szFmt,  ...);

		static void warn(const char* szFmt,  ...);
	
		static void error(const char* szFmt,  ...);

		static void fatal(const char* szFmt,  ...);
	};


	//
	//	macro for log interface with variable parameters
	//
#define LOG_DEBUG_V		woe::LoggerV::debug
#define LOG_WARN_V		woe::LoggerV::warn
#define LOG_INFO_V		woe::LoggerV::info
#define LOG_ERROR_V		woe::LoggerV::error
#define LOG_FATAL_V		woe::LoggerV::fatal

}


#endif
